import { dangrous_style } from "utils/constants/globalconstant";
import { PathFinderManager } from "../PathFinderManager";
import { ACostDecorate } from "./ACostDecorate";
import { cpu_used } from "utils/decorate/decorate";

/**
 * 设置避开地方单位，主要是NPC
 */
export class ACreepSetEludeHostile extends ACostDecorate
{
    
    decorate(manager:PathFinderManager,roomName: string, costs: CostMatrix,opt:IPathFinderOpt): CostMatrix 
    {
        // Game.rooms
        const station = global.world.PollHostiles(roomName);
        if(station )
        {

            for(let x in station.hostileDamageMap)
            {
                for(let y in station.hostileDamageMap[x])
                {
                    if(station.hostileDamageMap[x][y] )
                    {
                        costs.set(parseInt( x),parseInt(y),0x88);
                        Game.rooms[roomName]?.visual.text(`88`,parseInt( x),parseInt(y),dangrous_style)
                    }
                }
            }
            for(const e of station._friendCache)
            {
                costs.set(e.pos.x,e.pos.y,0xff);
            }
        }
        else
        {
            global.Log.Warning(`找不到 敌方爬的缓存 ${ roomName}, ${Game.rooms[roomName]?'此房间有视野':'此房间无视野'}`);
        }
        return  costs
    }

}